Attribute VB_Name = "Processi" Option Explicit Global hProcess As Long Public Const MAX_PATH As Integer = 260 Public Declare Function TerminateProcess Lib "Kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long Public Declare Function GetExitCodeProcess Lib "Kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long Global rProcess As Long Global tPID As Long Global tMID As Long Global hSnapShot As Long Public Declare Function ProcessFirst Lib "Kernel32" Alias "Process32First" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Public Declare Function ProcessNext Lib "Kernel32" Alias "Process32Next" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Public Declare Function CloseHandle Lib "Kernel32" (ByVal hFile As Long) As Long Public Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Public Declare Function CreateToolhelpSnapshot Lib "Kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long th32ParentProcessID As Long pcPriClassBase As Long dwFlags As Long szExeFile As String * MAX_PATH End Type Global uProcess As PROCESSENTRY32 Public Const TH32CS_SNAPPROCESS = &H2 Public Const PROCESS_TERMINATE = &H1 Public Function ProcessiAperti(ByVal Programma As String) As Boolean hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&) Dim MM As Long ProcessiAperti = False If hSnapShot <> 0 Then uProcess.dwSize = Len(uProcess) rProcess = ProcessFirst(hSnapShot, uProcess) Do While rProcess tPID = uProcess.th32ProcessID tMID = uProcess.th32ModuleID MM = InStr(1, UCase(uProcess.szExeFile), UCase(Programma)) If MM > 0 Then ProcessiAperti = True Exit Do Else ProcessiAperti = False End If rProcess = ProcessNext(hSnapShot, uProcess) Loop Call CloseHandle(hSnapShot) End If End Function